// 导入包
const KoaRouter = require('koa-router')

//自己写的
const {
	register,
	login,
	getAllUserInfo,
	modifyUser,
	searchUsers
} = require('../controller/user.controller')
const {
	userValidator,
	verifyUser,
	isAlreadyExistence,
	verifyModify
} = require('../middleware/user.middleware')
const {auth} = require('../middleware/auth.middleware')

//实例化对象
const UserRouter = new KoaRouter({ prefix: '/users' })

//编写路由
UserRouter.post('/register', userValidator,verifyUser, register)
UserRouter.post('/login', userValidator , isAlreadyExistence, login)

UserRouter.get('/getAllUserInfo',getAllUserInfo)
UserRouter.patch('/modifyUser',verifyModify,modifyUser)
UserRouter.get('/searchUsers',searchUsers)


module.exports = UserRouter